// /////////////////////////////////////////////////////////////////////////////
//
// Name:            asScriptManager.cpp
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Binds the ScriptManager class to AngelScript
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

// Include files
#include "asScriptManager.h"


#ifdef __COMPILE_WITH_ANGELSCRIPT__

#include "../ScriptHelper.h"

#include "../ScriptManager.h"


//! Binds the ScriptManager class to AngelScript.
void bindScriptManager(asIScriptEngine *engine)
{
    // Forward declarations.
    int r;

    // Bind DataStore class.
    r = engine->RegisterObjectType("ScriptManager", sizeof(ScriptManager), asOBJ_REF); assert(r >= 0);

    // Set DataStore behaviour.
    r = engine->RegisterObjectBehaviour("ScriptManager", asBEHAVE_ADDREF, "void f()",
                                        asMETHOD(ScriptManager, grab), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectBehaviour("ScriptManager", asBEHAVE_RELEASE, "void f()",
                                        asMETHOD(ScriptManager, drop), asCALL_THISCALL); assert(r >= 0);

    // Bind DataStore class functions.
    r = engine->RegisterObjectMethod("ScriptManager", "void init()",
                                     asMETHOD(ScriptManager, init), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ScriptManager", "void clear()",
                                     asMETHOD(ScriptManager, clear), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("ScriptManager", "bool addScript(Script @+)",
                                     asMETHOD(ScriptManager, addScript), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScript(const string &in)",
                                     asMETHOD(ScriptManager, createScript), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScript(const string &in, bool)",
                                     asMETHOD(ScriptManager, createScript), asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScriptFromFile(const string &in)",
                                     asMETHODPR(ScriptManager, createScriptFromFile, (const std::string&, bool), Script*),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScriptFromFile(const string &in, bool)",
                                     asMETHODPR(ScriptManager, createScriptFromFile, (const std::string&, bool), Script*),
                                     asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("ScriptManager", "Script@ getScript(const u32)",
                                     asMETHODPR(ScriptManager, getScript, (const u32), Script*),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ScriptManager", "Script@ getScript(const string &in)",
                                     asMETHODPR(ScriptManager, getScript, (const std::string &), Script*),
                                     asCALL_THISCALL); assert(r >= 0);

    r = engine->RegisterObjectMethod("ScriptManager", "void removeScripts()",
                                     asMETHOD(ScriptManager, removeScripts), asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ScriptManager", "bool removeScript(Script @+)",
                                     asMETHODPR(ScriptManager, removeScript, (Script*), bool),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ScriptManager", "bool removeScript(const u32)",
                                     asMETHODPR(ScriptManager, removeScript, (const u32), bool),
                                     asCALL_THISCALL); assert(r >= 0);
    r = engine->RegisterObjectMethod("ScriptManager", "bool removeScript(const string &in)",
                                     asMETHODPR(ScriptManager, removeScript, (const std::string &), bool),
                                     asCALL_THISCALL); assert(r >= 0);
}

#endif // __COMPILE_WITH_ANGELSCRIPT__

// End of File
